﻿using System;
using System.Collections.Generic;
using System.Linq;
using JTLeigh.Commerce.Spencer.Core.Common;
using ProductFeedbackE = JTLeigh.Commerce.Spencer.Features.ProductFeedback.Common.Entities.ProductFeedback;

namespace JTLeigh.Commerce.Spencer.Features.ProductFeedback.Business.Behaviors.ProductFeedbackSelection
{

    /// <summary>
    /// Behavior used to select product feedback ordered by date (ascending).
    /// </summary>
    public class DateAscendingBehavior : IProductFeedbackSelectionBehavior
    {

        #region IProductFeedbackSelectionBehavior Members

        /// <summary>
        /// Selects product feedback.
        /// </summary>
        /// <param name="feedback">The <see cref="Dictionary{TKey,TValue}"/> of 
        /// <see cref="ProductFeedback"/> objects to select from.</param>
        /// <returns>An ordered <see cref="IList{T}"/> of the selected <see cref="ProductFeedbackE"/>
        /// objects.</returns>
        public IList<ProductFeedbackE> SelectProductFeedback(Dictionary<Guid, ProductFeedbackE> feedback)
        {
            Safety.AssertArgumentNotNull("feedback", feedback);

            return (from f in feedback.Values orderby f.DateAdded ascending select f).ToList();
        }  

        #endregion // IProductFeedbackSelectionBehavior Members

    }

}
